<?php
  class tmcContactMailer extends Swift_Message {
    public function __construct(tmcContact $contact)
    {
      sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Partial'));
      $body = get_partial(sfConfig::get('app_tmcContactPlugin_email_partial', 'tmcContact/email'), array('object' => $contact));
      $subject = __(sfConfig::get('app_tmcContactPlugin_email_subject', 'contact form subject'), array(), 'tmcContactPlugin');
      
      parent::__construct($subject, $body, 'text/html');
      $this->setFrom($contact->getEmail()); //sfConfig::get('app_tmcContactPlugin_email_from', 'from@example.com')

      $to = sfConfig::get('app_tmcContactPlugin_email_to');//array('ecouvreur@yahoo.fr', 'postmaster@cpfaizenay.com');

      $this->setTo($to);
      
      if ( sfConfig::get('app_tmcContactPlugin_cc_to_sender', false) ){
        $this->addCc($contact->getEmail());
      }
    }
  }